package com.mjlf.aspect.aopt;

import com.mjlf.aspect.entity.User;
import com.mjlf.aspect.entity.User1;
import com.mjlf.aspect.entity.UserDao;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Aspect("perthis(this(com.mjlf.aspect.entity.User))")
@Component
@Scope("prototype")
public class UAspect {

//    @DeclareParents(value = "com.mjlf.aspect.entity.User+", defaultImpl = User1.class)
//    public UserDao user1;

    //定义一个切点
//    @Pointcut("execution(public void com.mjlf.aspect.entity.User.checkName())")
    @Pointcut("execution(public void com.mjlf.aspect.entity.User.*())")
    public void checkName(){}



    @Before("checkName()")
    public void checkNameAop(JoinPoint joinPoint) throws Throwable {
        System.out.println("hahaha");
        System.out.println("-----" + this.hashCode());
        System.out.println(joinPoint.getSignature());
    }
}





